package cn.bjc._06_oneWay;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {
    public static void main(String[] args) throws Exception {
        //1.实例化生产者
        DefaultMQProducer producer = new DefaultMQProducer("oneWay_producer_group");

        //2.设置nameserver
        producer.setNamesrvAddr("localhost:9876");

        //3.启动生产者
        producer.start();

        //4.创建消息,设置消息内容
        Message message = new Message("oneWay", "hello", "消息发送来了哦".getBytes(StandardCharsets.UTF_8));
        producer.sendOneway(message);

        //5.关闭
        producer.shutdown();
        
    }
}
